/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-08-11
 * Time: 14:03
 */
public class Test {
    public static int pivotIndex(int[] nums) {
        int len = nums.length;
        int tatol = 0;
        for (int i = 0; i < len; i++) {
            tatol += nums[i];
        }
        int sum = 0;
        for (int i = 0; i < len; i++) {
            if(sum * 2 + nums[i] == tatol ){
                return i;
            }
            sum += nums[i];
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] arry = {3,1,2,4,5,8};
        int ret = pivotIndex(arry);
        System.out.println(ret);
    }
    public static int[] sortArrayByParity(int[] nums) {
        int len = nums.length;
        int[] arry = new int[len];
        int left = 0;
        int right = len - 1;
        for (int i = 0; i < len; i++) {
            if(nums[i] % 2 == 0){
                arry[left] = nums[i];
                left++;
            }else {
                arry[right] = nums[i];
                right--;
            }
        }
        return arry;
    }
    public static void main2(String[] args) {
        int[] arry = {3,1,2,4};
        int[] ret = sortArrayByParity(arry);
        for (int x : ret) {
            System.out.print(x+" ");
        }
    }
    public static void print(){
        System.out.println("MTDP");
    }
    public static void main1(String[] args) {
        try{
            ((Test)null).print();
        }catch(NullPointerException e){
            System.out.println("NullPointerException");
        }
    }
}
